package BitManipulation;

public class _342_PowerofFour {
    //solution 1:sue loop
    public boolean isPowerOfFour_0(int num) {
        if (num == 0) {
            return false;
        }
        while (num % 4 == 0) {
            num /= 4;
        }
        return num == 1;
    }

    //solution 2:use bit manipulation
    public boolean isPowerOfFour(int num) {
        while (num != 0) {
            if (num == 1) {
                return true;
            }
            if ((num & 3) != 0) {
                return false;
            }
            num = num>> 2;
        }
        return false;
    }
}
